package com.wiloon.java8x.sort;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: wiloon
 * Date: 9/16/12
 * Time: 3:44 PM
 */

//测试类

public class SortTest {

    public static void main(String[] args) {

        List userlist = new ArrayList();

        userlist.add(new User("dd", "4"));

        userlist.add(new User("aa", "1"));

        userlist.add(new User("ee", "5"));

        userlist.add(new User("bb", "2"));

        userlist.add(new User("ff", "5"));

        userlist.add(new User("cc", "3"));

        userlist.add(new User("gg", "6"));


        ComparatorUser comparator = new ComparatorUser();

        Collections.sort(userlist, comparator);


        for (int i = 0; i < userlist.size(); i++) {

            User user_temp = (User) userlist.get(i);

            System.out.println(user_temp.getAge() + "," + user_temp.getName());

        }


    }

}
//首先年龄排序，如果年龄相同，则按名字排序